package com.Liux.blog.controller;

import com.Liux.blog.entity.Article;
import com.Liux.blog.service.ArticleService;
import com.Liux.blog.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @PostMapping("/add")
    public ResultVo add(Article article){
        return  articleService.createArticle(article);
    }

    @GetMapping("/list")
    public ResultVo list(int pageNum,int limit){
        return articleService.ArticleList(pageNum,limit);
    }
    @GetMapping("/detail")
    public ResultVo detail(String aid){
        return articleService.ArticleById(aid);
    }
    @PostMapping("/update")
    public ResultVo update(String id,String title,String center){
        return  articleService.updateArticle(id,title,center);
    }
    @DeleteMapping("/delete")
    public ResultVo delete(String aid){
        return articleService.deleteArticle(aid);
    }
}
